
package sr.codemg.controller;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import sr.codemg.entity.SysRoles;
import sr.codemg.service.SysRolesService;
import sr.codemg.vm.Base;
import sr.codemg.vm.Selects;
import sr.codemg.vm.SysRolesEdit;
import sr.codemg.vm.Tables;

import java.util.Map;

/**
 * 权限信息
 **/
@Slf4j
@RestController
@RequestMapping("/sysroles")
public class SysRolesController {

    @Autowired
    SysRolesService sysRolesService;

    @GetMapping("/{id}")
    public SysRoles get(@PathVariable("id") String id) {
        return sysRolesService.get(id);
    }

    @GetMapping("/edit/{id}")
    public SysRoles getEdit(@PathVariable("id") String id) {
        return sysRolesService.getEdit(id);
    }

    @PutMapping
    public Tables list(@RequestBody Map<String, Object> params) {
        return sysRolesService.findList(params);
    }

    @PostMapping
    public Base.Response post(@RequestBody SysRolesEdit entity) {
        entity.setId(null);
        return sysRolesService.add(entity);
    }

    @PutMapping("/edit")
    public Base.Response put(@RequestBody SysRolesEdit entity) {
        return sysRolesService.update(entity);
    }

    @DeleteMapping("/{id}")
    public Base.Response delete(@PathVariable("id") String id) {
        return sysRolesService.delete(id);
    }

    @PostMapping("/select")
    public Selects.Response select(@RequestBody Selects.Request req) {
        return sysRolesService.select(req);
    }
}

